package cn.edu.cqupt.mis.ywbd.admin;

import cn.edu.cqupt.mis.ywbd.admin.dao.CollectionMapper;
import cn.edu.cqupt.mis.ywbd.admin.dao.QuestionMapper;
import cn.edu.cqupt.mis.ywbd.admin.dao.SubjectMapper;
import cn.edu.cqupt.mis.ywbd.admin.dto.ListQuestionDto;
import cn.edu.cqupt.mis.ywbd.admin.service.QuestionService;
import cn.edu.cqupt.mis.ywbd.admin.service.impl.QuestionServiceImpl;
import cn.edu.cqupt.mis.ywbd.admin.vo.QuestionListVo;
import cn.edu.cqupt.mis.ywbd.common.pojo.Collection;
import cn.edu.cqupt.mis.ywbd.common.pojo.Question;
import cn.edu.cqupt.mis.ywbd.common.pojo.Subject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 李国龙
 * @date 2021/3/30
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class AdminTestApplication {
    @Autowired
    private QuestionMapper questionMapper;
    @Autowired
    private CollectionMapper collectionMapper;
    @Autowired
    QuestionServiceImpl questionService;
    @Autowired
    SubjectMapper subjectMapper;

    @Test
    public void testQuestionDao() {
//        Page<Question> questionPage = questionMapper.selectPage(new Page<Question>(1, 1), null);
//        List<Question> records = questionPage.getRecords();
//        System.out.println(records);

//        List<Collection> collections = collectionMapper.selectList(null);
//        Question question = questionMapper.selectOne(new QueryWrapper<Question>().eq("title", "多少"));
//        System.out.println(question);
//        ListQuestionDto questionDto = new ListQuestionDto("", "高l", "经济管理学院", "李国龙", 1, "2021-03-03", "", 1, 1);
//        List<Object> objects = subjectMapper
//                .selectObjs(new QueryWrapper<Subject>()
//                        .like("subject_name", questionDto
//                                .getSubjectName())
//                        .select("subject_id"));
//        System.out.println(objects.isEmpty()?"":objects);
//        QueryWrapper<Question> questionQueryWrapper = new QueryWrapper<Question>()
//                .in("subject_id","");
//        List<Object> integers = new ArrayList<>();
//        integers.add(1);
//        integers.add(2);
//        QueryWrapper<Question> questionQueryWrapper2 = new QueryWrapper<Question>().in("subject_id",integers).select("title");
//        List questions = questionMapper.selectObjs(questionQueryWrapper2);
//        List<Object> subjectIds = subjectMapper.selectObjs(new QueryWrapper<Subject>()
//                .like("subject_name", questionDto.getSubjectName())
//                .like("college",questionDto.getCollege())
//                .select("subject_id"));
//        System.out.println(subjectIds);
//
//        List<Object> integers = new ArrayList<>();
//        integers.add(1);
//        integers.add(2);
//        QueryWrapper<Question> in = new QueryWrapper<Question>()
//                .in("subject_id", subjectIds.isEmpty() ? "" : integers);
//
//
//        System.out.println(questions);
//        System.out.println(questions);
//            questionService.listQuestion(questionDto);
//        System.out.println(questions);
//        System.out.println(collections);
        questionMapper.logicalDelete(1);
    }
}
